package xyz.sicau.test3_direct;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import xyz.sicau.utils.MQUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer1 {
    public static final String QUEUE = "hello";
    public static final String EXCHANGE = "MyJHJ";


    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = MQUtils.getChannel();

        // 获取队列，这里获取随机生产的队列，返回队列名
        channel.queueDeclare("disk",false,false,false,null);

        channel.queueBind("disk",EXCHANGE,"error");

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println(new String(message.getBody()));
        };

        CancelCallback cancelCallback = consumerTag -> {
            System.out.println("消息取消");
        };

        channel.basicConsume("disk",true,deliverCallback,cancelCallback);
    }
}
